﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////

#pragma once

// std headers
#include <iostream>

// Qt headers

// custom headers
#include "ImageProvider.h"


class QNetworkAccessManager;
class QNetworkRequest;

namespace gmepgcs
{
    class GCS_SERVICE_EXPORTS UrlImageProvider : public ImageProvider<std::wstring>
    {
        Q_OBJECT
    public:
        explicit UrlImageProvider(QObject *parent = nullptr);
        virtual ~UrlImageProvider();

    public:
        void Provide(std::wstring url) final;
        
    signals:
        void OnProvided(std::wstring url, std::shared_ptr<QImage> spImage);

    private:
        void ConfigureAuthorization(QNetworkRequest &request) const;

    private:
        std::shared_ptr<QNetworkAccessManager> m_spNetworkAccessManager;
    };
}